package com.ita.iosa.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.iosa.po.Merchant;
import com.ita.iosa.service.AdminManager;
import com.ita.iosa.service.impl.AdminManagerImpl;

/**
 * Servlet implementation class AdminOperateServlet
 */
public class AdminOperateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private AdminManager adminManager = new AdminManagerImpl();

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public AdminOperateServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HashMap<Integer, Integer> allMerchantStatus = new HashMap<Integer, Integer>();
		
		List<Merchant> passMerchants = new ArrayList<Merchant>();
		
		allMerchantStatus = adminManager.showAllMerchantStatus();
		
		passMerchants = adminManager.showPassMerchants();
		
		if (!passMerchants.isEmpty()) {
			request.setAttribute("passMerchants", passMerchants);
		}
		else {
			request.setAttribute("NONE1", "No pass merhcant");
		}
		
		request.getRequestDispatcher("/iosa/jsp/admin/active.jsp").forward(request, response);
	}
}
